package com.bruce.spring.http.api;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PutExchange;

import java.util.Map;
import java.util.Set;

/**
 * Created by bruce in 2025/6/17 02:05
 *
 * <a href="https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface">Spring rest-clients</a>
 */
@HttpExchange("/order")
public interface OrderClient {


    // POST application/json请求
    // 此时如果方法参数不使用@RequestBody, SpringMVC不会从body中读取数据
    @PutExchange(value = "/putJsonStores")
    Page<Store> putJsonStores(@RequestBody Store store);

    // POST 表单请求,
    @PutExchange(value = "/putFromStores", contentType = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    Page<Store> putFormStores(Store store);

    @PutExchange(value = "/requestMap", contentType = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    Store requestMap(@RequestParam Map<String, String> params);

    @PutExchange(value = "/requestMapBody")
    Map<String, String> requestMapBody(@RequestBody Map<String, String> params);

    // 返回 ResponseEntity<Store>
    @PutExchange(value = "/responseEntity", contentType = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    ResponseEntity<Store> responseEntity(@RequestParam Map<String, String> params);

    @PutExchange(value = "/stores/{storeId}", contentType = "application/json")
    Store usePathVars(@PathVariable("storeId") Long storeId, @RequestBody Store store);

    @GetExchange("/secrets/{secretId}/keys")
    Set<String> keySet(@PathVariable("secretId") Long secretId,
                       @RequestParam(value = "version", required = false) Long version);

}
